Java的list筛选重复的数据然后移除掉 发表于 2021-09-26 | 次阅读 字数统计: 131 字 | 阅读时长 ≈ 1 min 123456789101112131415161718192021222324/** * 筛选出重复数据然后然移除掉; * @author wjk * @Date 2021-09-16 */private List<AttendEmployeeMonth> getAttendEmployeeMonthRmHaveAttendEmployee(List<AttendEmployeeMonth> attendEmployeeMonthList) { //根据列表查询这些员工是否已经做过考勤记录 List<AttendEmployeeMonth> attendEmployeeMonthListOld = attendEmployeeMonthService.getEmployeeListByAuditBtyArchiveList(attendEmployeeMonthList); //若有,则剔除掉该员工,重新组成列表, List<AttendEmployeeMonth> attendEmployeeMonthNew = new ArrayList<AttendEmployeeMonth>(); for(AttendEmployeeMonth attendEmployeeMonth :attendEmployeeMonthList){ for(AttendEmployeeMonth attendEmployeeMonthOld : attendEmployeeMonthListOld){ if (attendEmployeeMonth.getBtyArchicesId().equals(attendEmployeeMonthOld.getBtyArchicesId())){ attendEmployeeMonthNew.add(attendEmployeeMonth); } } } attendEmployeeMonthList.removeAll(attendEmployeeMonthNew); //若没有,直接进行之后的操作 return attendEmployeeMonthList;} 欢迎加我的微信,共同交流技术